<template>
    <div>
        <h1>登录</h1>
        <table class="table table-bordered">
           <tbody>
                <tr>
                    <td>账号</td>
                    <td><input type="text" v-model="info.name" /></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="info.pwd" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button"  class="btn btn-success" value="登录" @click="d"/></td>
                </tr>
           </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { onMounted,reactive,ref } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';

const route=useRoute();
const router=useRouter();

let info=reactive({
    name:'',
    pwd:''
})
const d=()=>{
    axios({
        url:'/api/User/Deng',
        method:'get',
        params:info
    })
    .then(res=>{
        console.log(res);
        if(res.data==-1){
            alert('账号不正确!');
            return;
        }
        else if(res.data==-2){
            alert('密码不正确!');
            return;
        }
        else if(res.data==1){
            alert('登陆成功!');
            router.push('/RoomXList');
        }
    })
}

</script>